Skip to content

Add hidraw backend for FreeBSD#730

Open
aokblast wants to merge 2 commits intolibusb:masterfrom
aokblast:use_hid_raw
Open

Add hidraw backend for FreeBSD#730
aokblast wants to merge 2 commits intolibusb:masterfrom
aokblast:use_hid_raw

Conversation

@aokblast
Copy link
Copy Markdown

FreeBSD support hidraw in Kernel from 13.0.
By using libusb only, we can only see the HID device from usb. To address this, we implement hidraw backend for FreeBSD.

Just like Linux use libudev to handle usb specified HID stuff (like Manufacture), we use libusb to handle it.

Sponsored-by: FreeBSD Foundation

@aokblast
Copy link
Copy Markdown
Author

Currently, some stuff like the Report Descriptor parser and error registry routine are copied from Linux and I think they are platform independent. Can we create a common directory or hidraw directory in code then put them inside?

Have tested by the hidtest program.

@Youw Youw self-requested a review March 27, 2025 10:33
@Youw Youw added enhancement New feature or request bsd FreeBSD, NetBSD, OpenBSD, etc labels Mar 27, 2025
Comment thread freebsd/Makefile-manual
Comment thread libusb/Makefile.in Outdated
Comment thread src/CMakeLists.txt Outdated
Comment thread freebsd/CMakeLists.txt Outdated
Comment thread freebsd/hid.c Outdated
Comment thread freebsd/hid.c Outdated
Comment thread freebsd/hid.c Outdated
Copy link
Copy Markdown
Member

@Youw Youw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more comments

@aokblast aokblast force-pushed the use_hid_raw branch 4 times, most recently from 49a7a62 to 6e7a25a Compare March 27, 2025 14:16
@aokblast
Copy link
Copy Markdown
Author

Thanks for @Youw your review:).

Then, What is your opinion about this?

Currently, some stuff like the Report Descriptor parser and error registry routine are copied from Linux and I think they are platform independent. Can we create a common directory or hidraw directory in code then put them inside?

Have tested by the hidtest program.

@Youw
Copy link
Copy Markdown
Member

Youw commented Mar 27, 2025

Thanks for @Youw your review:).

Then, What is your opinion about this?

Currently, some stuff like the Report Descriptor parser and error registry routine are copied from Linux and I think they are platform independent. Can we create a common directory or hidraw directory in code then put them inside?
Have tested by the hidtest program.

I thinjk that is a good idea, but I don't think it really is nesessary to do so in scope of this PR.
There are really lots of stuff which I'd like to share among beckends, and I think it is going to be some refactoring after all.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Mar 28, 2025

Nice. This will address the following issue.

@aokblast
Copy link
Copy Markdown
Author

Oops. I forget we have udev-devd stuff. Maybe we should use udev also?

@Youw
Copy link
Copy Markdown
Member

Youw commented Mar 28, 2025

Oops. I forget we have udev-devd stuff. Maybe we should use udev also?

I lost context here. What for? Seem like you have all the functionality implemented already. Aren't you?

@aokblast
Copy link
Copy Markdown
Author

Oops. I forget we have udev-devd stuff. Maybe we should use udev also?

I lost context here. What for? Seem like you have all the functionality implemented already. Aren't you?

Yes, all functionality is fully implemented. I am just thinking if we should use libudev make hidapi more portable.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Mar 30, 2025

First test under FreeBSD 14.1 Release, under a physical machine (Chuwi mini PC, Intel J4125 CPU, 8GB RAM, 256GB SSD)

There are a few compiler warnings.

mcuee@freebsd14:~/build/hidapi_pr730 $ uname -a
FreeBSD freebsd14 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64

mcuee@freebsd14:~/build/hidapi_pr730 $ cc -v
FreeBSD clang version 18.1.5 (https://github.com/llvm/llvm-project.git llvmorg-18.1.5-0-g617a15a9eac9)
Target: x86_64-unknown-freebsd14.1
Thread model: posix
InstalledDir: /usr/bin

mcuee@freebsd14:~/build/hidapi_pr730 $ make
make  all-recursive
Making all in freebsd
  CC       hid.lo
hid.c:396:24: warning: passing 'uint8_t[255]' (aka 'unsigned char[255]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
  396 |                 mbstowcs(namebuffer, buffer, sizeof(namebuffer));
      |                                      ^~~~~~
/usr/include/stdlib.h:107:64: note: passing argument to parameter here
  107 | size_t   mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
      |                                                                 ^
hid.c:603:1: warning: non-void function does not return a value [-Wreturn-type]
  603 | }
      | ^
hid.c:937:7: warning: passing 'const char *' to parameter of type 'void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
  937 |         free(dev->device_path);
      |              ^~~~~~~~~~~~~~~~
/usr/include/stdlib.h:101:18: note: passing argument to parameter here
  101 | void     free(void *);
      |                     ^
3 warnings generated.
  CCLD     libhidapi-hidraw.la
Making all in libusb
  CC       hid.lo
  CCLD     libhidapi-libusb.la
Making all in hidtest
  CC       test.o
  CCLD     hidtest-libusb
  CCLD     hidtest-hidraw

@aokblast
Copy link
Copy Markdown
Author

Fix it:). Forget to fix the warning.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Mar 30, 2025

Somehow hidtest-hidraw will seg fault with the Microchip Simple HID example.

mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./hidtest/hidtest-hidraw
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.

Segmentation fault
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./hidtest/hidtest-libusb
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 04f2 0760
  path: 0-3:1.0
  serial_number: (null)
  Manufacturer: Chicony
  Product:      USB Keyboard
  Release:      100
  Interface:    0
  Usage (page): 0x0 (0x0)
  Bus type: 1 (USB)

  Report Descriptor: (65 bytes)
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0, 
0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 
0x81, 0x02, 0x95, 0x01, 0x75, 0x08, 0x81, 0x01, 0x95, 0x03, 
0x75, 0x01, 0x05, 0x08, 0x19, 0x01, 0x29, 0x03, 0x91, 0x02, 
0x95, 0x05, 0x75, 0x01, 0x91, 0x01, 0x95, 0x06, 0x75, 0x08, 
0x15, 0x00, 0x26, 0xff, 0x00, 0x05, 0x07, 0x19, 0x00, 0x2a, 
0xff, 0x00, 0x81, 0x00, 0xc0, 
Device Found
  type: 04f2 0760
  path: 0-3:1.1
  serial_number: (null)
  Manufacturer: Chicony
  Product:      USB Keyboard
  Release:      100
  Interface:    1
  Usage (page): 0x0 (0x0)
  Bus type: 1 (USB)

  Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19, 
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0, 
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00, 
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8, 
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02, 
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a, 
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25, 
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a, 
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01, 
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02, 
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1, 
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0, 
Device Found
  type: 1ea7 0064
  path: 0-4:1.0
  serial_number: (null)
  Manufacturer: (null)
  Product:      2.4G Mouse
  Release:      200
  Interface:    0
  Usage (page): 0x0 (0x0)
  Bus type: 1 (USB)

  Report Descriptor: (105 bytes)
0x06, 0xb5, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0xb5, 0x09, 
0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x07, 
0x81, 0x02, 0x09, 0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 
0x08, 0x95, 0x07, 0x91, 0x02, 0xc0, 0x05, 0x01, 0x09, 0x02, 
0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09, 
0x19, 0x01, 0x29, 0x08, 0x15, 0x00, 0x25, 0x01, 0x95, 0x08, 
0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x81, 0x06, 0x09, 0x38, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08, 
0x95, 0x01, 0x81, 0x06, 0x05, 0x0c, 0x0a, 0x38, 0x02, 0x95, 
0x01, 0x81, 0x06, 0xc0, 0xc0, 
Device Found
  type: 04d8 003f
  path: 0-2:1.0
  serial_number: (null)
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x0 (0x0)
  Bus type: 1 (USB)

  Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29, 
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81, 
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0, 
Manufacturer String: Microchip Technology Inc.
Product String: Simple HID Device Demo
Unable to read serial number string
Serial Number String: (0) 
  Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29, 
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81, 
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0, 
Device Found
  type: 04d8 003f
  path: 0-2:1.0
  serial_number: (null)
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x1 (0xff00)
  Bus type: 1 (USB)

Indexed String 1: Microchip Technology Inc.
Unable to send a feature report: hid_error is not implemented yet
Unable to get a feature report: hid_error is not implemented yet
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
read() timeout

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Mar 30, 2025

Fix it:). Forget to fix the warning.

Thanks. The compiler warnings are gone.

The Segfault issue is still there though.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

Latest version of VirtualBox does not seem to allow me to disable EHCI support so I can not carry out the test. I am not so sure if I still have working USB 1.1 Hub to try.

man ehci tells us about hw.usb.ehci.no_hs loader tunable that disables High Speed. Try to add hw.usb.ehci.no_hs="1" to /boot/loader.conf and reboot after than

Thanks for the tip. I will try this soon.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

man ehci tells us about hw.usb.ehci.no_hs loader tunable that disables High Speed. Try to add hw.usb.ehci.no_hs="1" to /boot/loader.conf and reboot after than

Somehow this does not work. The device is still enumerated as a high speed USB device.

mcuee@freebsdvm:~/build/hidapitester $ sudo cat /boot/loader.conf
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gptid.enable="0"
zfs_load="YES"
hw.usb.ehci.no_hs="1"

mcuee@freebsdvm:~/build/hidapitester $ sudo reboot
Connection to 127.0.0.1 closed by remote host.
Connection to 127.0.0.1 closed.

PS C:\work> ssh mcuee@127.0.0.1 -p 3224
(mcuee@127.0.0.1) Password for mcuee@freebsdvm:
Last login: Sat Apr 25 19:58:23 2026 from 10.0.2.2
FreeBSD 15.0-RELEASE-p4 (GENERIC) releng/15.0-n281010-8ef0ed690df2

Welcome to FreeBSD!
...
...

mcuee@freebsdvm:~ $ cd build/

mcuee@freebsdvm:~/build $ cd hidapitester/

mcuee@freebsdvm:~/build/hidapitester $ sudo kldload hidraw

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw --list
0925/1234: CYPRESS - CYPRESS EZ-USB FX2 HID USBHIDIO

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_libusb --vidpid 0925:1234 --open --buflen 64 -l 3 --sen
d-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw --vidpid 0925:1234 --open --buflen 64 -l 3 --sen
d-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo usbconfig list
ugen1.1: <EHCI root HUB Intel> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen0.1: <OHCI root HUB Apple> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)
ugen1.2: <EZ-USB FX2 HID USBHIDIO Lakeview Research> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (80mA)

Bus /dev/usb Device /dev/ugen1.2: ID 0925:1234 Lakeview Research
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x0925 Lakeview Research
  idProduct          0x1234
  bcdDevice            0.00
  iManufacturer           1 CYPRESS
  iProduct                2 EZ-USB FX2 HID USBHIDIO
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          3
    bmAttributes         0x80
      (Bus Powered)
    MaxPower               80mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      52
          Report Descriptor: (length is 52)
            Item(Global): Usage Page, data= [ 0xa0 0xff ] 65440
                            (null)
            Item(Local ): Usage, data= [ 0x01 ] 1
                            (null)
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Local ): Usage, data= [ 0x02 ] 2
                            (null)
            Item(Main  ): Collection, data= [ 0x00 ] 0
                            Physical
            Item(Global): Usage Page, data= [ 0xa1 0xff ] 65441
                            (null)
            Item(Local ): Usage, data= [ 0x03 ] 3
                            (null)
            Item(Local ): Usage, data= [ 0x04 ] 4
                            (null)
            Item(Global): Logical Minimum, data= [ 0x80 ] 128
            Item(Global): Logical Maximum, data= [ 0x7f ] 127
            Item(Global): Physical Minimum, data= [ 0x00 ] 0
            Item(Global): Physical Maximum, data= [ 0xff ] 255
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x05 ] 5
                            (null)
            Item(Local ): Usage, data= [ 0x06 ] 6
                            (null)
            Item(Global): Logical Minimum, data= [ 0x80 ] 128
            Item(Global): Logical Maximum, data= [ 0x7f ] 127
            Item(Global): Physical Minimum, data= [ 0x00 ] 0
            Item(Global): Physical Maximum, data= [ 0xff ] 255
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Main  ): Output, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
            Item(Main  ): End Collection, data=none
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         4
  bNumConfigurations      1
can't get debug descriptor: Input/output error
Device Status:     0x0002
  (Bus Powered)
  Remote Wakeup Enabled

Bus /dev/usb Device /dev/ugen0.1: ID 0000:0000
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.00
  bDeviceClass            9 Hub
  bDeviceSubClass         0 Unused
  bDeviceProtocol         0 Full speed (or root) hub
  bMaxPacketSize0        64
  idVendor           0x0000
  idProduct          0x0000
  bcdDevice            1.00
  iManufacturer           1 Apple
  iProduct                2 OHCI root HUB
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           25
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x40
      (Missing must-be-set bit!)
      Self Powered
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      0 Full speed (or root) hub
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval             255
Hub Descriptor:
  bLength              10
  bDescriptorType      41
  nNbrPorts            12
  wHubCharacteristic 0x0002
    No power switching (usb 1.0)
    Ganged overcurrent protection
  bPwrOn2PwrGood        0 * 2 milli seconds
  bHubContrCurrent      0 milli Ampere
  DeviceRemovable    0x00 0x00
  PortPwrCtrlMask    0x00 0x00
 Hub Port Status:
   Port 1: 0000.0100 power
   Port 2: 0000.0100 power
   Port 3: 0000.0100 power
   Port 4: 0000.0100 power
   Port 5: 0000.0100 power
   Port 6: 0000.0100 power
   Port 7: 0000.0100 power
   Port 8: 0000.0100 power
   Port 9: 0000.0100 power
   Port 10: 0000.0100 power
   Port 11: 0000.0100 power
   Port 12: 0000.0100 power
Device Status:     0x0001
  Self Powered

Bus /dev/usb Device /dev/ugen1.1: ID 0000:0000
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            9 Hub
  bDeviceSubClass         0 Unused
  bDeviceProtocol         1 Single TT
  bMaxPacketSize0        64
  idVendor           0x0000
  idProduct          0x0000
  bcdDevice            1.00
  iManufacturer           1 Intel
  iProduct                2 EHCI root HUB
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           25
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x40
      (Missing must-be-set bit!)
      Self Powered
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      0 Full speed (or root) hub
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval             255
Hub Descriptor:
  bLength              10
  bDescriptorType      41
  nNbrPorts            12
  wHubCharacteristic 0x0002
    No power switching (usb 1.0)
    Ganged overcurrent protection
    TT think time 8 FS bits
  bPwrOn2PwrGood      200 * 2 milli seconds
  bHubContrCurrent      0 milli Ampere
  DeviceRemovable    0x00 0x00
  PortPwrCtrlMask    0x00 0x00
 Hub Port Status:
   Port 1: 0000.0501 highspeed power connect
   Port 2: 0000.0500 highspeed power
   Port 3: 0000.0500 highspeed power
   Port 4: 0000.0500 highspeed power
   Port 5: 0000.0500 highspeed power
   Port 6: 0000.0500 highspeed power
   Port 7: 0000.0500 highspeed power
   Port 8: 0000.0500 highspeed power
   Port 9: 0000.0500 highspeed power
   Port 10: 0000.0500 highspeed power
   Port 11: 0000.0500 highspeed power
   Port 12: 0000.0500 highspeed power
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            9 Hub
  bDeviceSubClass         0 Unused
  bDeviceProtocol         0 Full speed (or root) hub
  bMaxPacketSize0         0
  bNumConfigurations      0
can't get debug descriptor: Input/output error
Device Status:     0x0001
  Self Powered

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

The following command seems to disable EHCI driver completely, but then somehow I cannot attach the FX2LP USB HID device. Only a generic Atmel STK600 can be attached.

mcuee@freebsdvm:~/build/hidapitester $ sudo cat /boot/loader.conf
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gptid.enable="0"
zfs_load="YES"
hint.ehci.0.disabled="1"
hint.ehci.1.disabled="1"

mcuee@freebsdvm:~/build/hidapitester $ sudo reboot
Connection to 127.0.0.1 closed by remote host.
Connection to 127.0.0.1 closed.

PS C:\work> ssh mcuee@127.0.0.1 -p 3224
(mcuee@127.0.0.1) Password for mcuee@freebsdvm:
Last login: Sat Apr 25 20:26:59 2026 from 10.0.2.2
FreeBSD 15.0-RELEASE-p4 (GENERIC) releng/15.0-n281010-8ef0ed690df2

Welcome to FreeBSD!
...
...
mcuee@freebsdvm:~ $ sudo usbconfig list
ugen0.1: <OHCI root HUB Apple> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)
ugen0.2: <STK600 development board Atmel Corp.> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (500mA)

mcuee@freebsdvm:~ $ sudo dmesg | grep usb
usbus0 on ohci0
usbus0: 12Mbps Full Speed USB v1.0
ugen0.1: <Apple OHCI root HUB> at usbus0
uhub0 on usbus0
uhub0: <Apple OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus0
ugen0.2: <ATMEL STK600> at usbus0

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

Okay, this seems to work.

PS C:\Program Files\Oracle\VirtualBox> .\VBoxManage modifyvm "freebsd" --usb-ohci on --usb-ehci off --usb-xhci off

Now it seems to work.

mcuee@freebsdvm:~/build/hidapitester $ sudo usbconfig list
ugen0.1: <OHCI root HUB Apple> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)
ugen0.2: <EZ-USB FX2 HID USBHIDIO Lakeview Research> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (80mA)

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_libusb --vidpid 0925:1234 --open --buflen 64 -l 3 --sen
d-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo lsusb -d 0925:1234 -vvv

Bus /dev/usb Device /dev/ugen0.2: ID 0925:1234 Lakeview Research
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x0925 Lakeview Research
  idProduct          0x1234
  bcdDevice            0.00
  iManufacturer           1 CYPRESS
  iProduct                2 EZ-USB FX2 HID USBHIDIO
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          3
    bmAttributes         0x80
      (Bus Powered)
    MaxPower               80mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      52
          Report Descriptor: (length is 52)
            Item(Global): Usage Page, data= [ 0xa0 0xff ] 65440
                            (null)
            Item(Local ): Usage, data= [ 0x01 ] 1
                            (null)
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Local ): Usage, data= [ 0x02 ] 2
                            (null)
            Item(Main  ): Collection, data= [ 0x00 ] 0
                            Physical
            Item(Global): Usage Page, data= [ 0xa1 0xff ] 65441
                            (null)
            Item(Local ): Usage, data= [ 0x03 ] 3
                            (null)
            Item(Local ): Usage, data= [ 0x04 ] 4
                            (null)
            Item(Global): Logical Minimum, data= [ 0x80 ] 128
            Item(Global): Logical Maximum, data= [ 0x7f ] 127
            Item(Global): Physical Minimum, data= [ 0x00 ] 0
            Item(Global): Physical Maximum, data= [ 0xff ] 255
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x05 ] 5
                            (null)
            Item(Local ): Usage, data= [ 0x06 ] 6
                            (null)
            Item(Global): Logical Minimum, data= [ 0x80 ] 128
            Item(Global): Logical Maximum, data= [ 0x7f ] 127
            Item(Global): Physical Minimum, data= [ 0x00 ] 0
            Item(Global): Physical Maximum, data= [ 0xff ] 255
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Main  ): Output, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
            Item(Main  ): End Collection, data=none
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
Device Status:     0x0002
  (Bus Powered)
  Remote Wakeup Enabled

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

Going back to the device with HID Input/Output report size of 128 bytes.

It seems to this PR will work fine as well.

Good thing -- PR #728 also works fine.

mcuee@freebsdvm:~/build/hidapitester $ sudo usbconfig list
ugen0.1: <OHCI root HUB Apple> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)
ugen0.2: <EZ-USB FX2 HID USBHIDIO Lakeview Research> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (80mA)
mcuee@freebsdvm:~/build/hidapitester $ sudo lsusb -d 0925:1234 -vvv

Bus /dev/usb Device /dev/ugen0.2: ID 0925:1234 Lakeview Research
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x0925 Lakeview Research
  idProduct          0x1234
  bcdDevice            0.00
  iManufacturer           1 CYPRESS
  iProduct                2 EZ-USB FX2 HID USBHIDIO
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          3
    bmAttributes         0x80
      (Bus Powered)
    MaxPower               80mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      52
          Report Descriptor: (length is 52)
            Item(Global): Usage Page, data= [ 0xa0 0xff ] 65440
                            (null)
            Item(Local ): Usage, data= [ 0x01 ] 1
                            (null)
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Local ): Usage, data= [ 0x02 ] 2
                            (null)
            Item(Main  ): Collection, data= [ 0x00 ] 0
                            Physical
            Item(Global): Usage Page, data= [ 0xa1 0xff ] 65441
                            (null)
            Item(Local ): Usage, data= [ 0x03 ] 3
                            (null)
            Item(Local ): Usage, data= [ 0x04 ] 4
                            (null)
            Item(Global): Logical Minimum, data= [ 0x80 ] 128
            Item(Global): Logical Maximum, data= [ 0x7f ] 127
            Item(Global): Physical Minimum, data= [ 0x00 ] 0
            Item(Global): Physical Maximum, data= [ 0xff ] 255
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x80 ] 128
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x05 ] 5
                            (null)
            Item(Local ): Usage, data= [ 0x06 ] 6
                            (null)
            Item(Global): Logical Minimum, data= [ 0x80 ] 128
            Item(Global): Logical Maximum, data= [ 0x7f ] 127
            Item(Global): Physical Minimum, data= [ 0x00 ] 0
            Item(Global): Physical Maximum, data= [ 0xff ] 255
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x80 ] 128
            Item(Main  ): Output, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
            Item(Main  ): End Collection, data=none
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
Device Status:     0x0002
  (Bus Powered)
  Remote Wakeup Enabled

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw --vidpid 0925:1234 --open --buflen 256 -l 129 --send-output 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 129-bytes...wrote 129 bytes:
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
 80
Reading up to 129-byte input report, 250 msec timeout...read 128 bytes:
 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40
 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60
 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80
 00
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr728_libusb --vidpid 0925:1234 --open --buflen 256 -l 129 --
send-output 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,3
9,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,7
9,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,11
4,115
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 129-bytes...wrote 129 bytes:
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
 80
Reading up to 129-byte input report, 250 msec timeout...read 128 bytes:
 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40
 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60
 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80
 00
Closing device

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

@aokblast @wulf7 and @cederom

So basically this PR works with Full Speed USB HID device, but somehow it does not work with High Speed USB HID device. It may not be an issue with this PR, but rather the hidraw driver issue under FreeBSD.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

@Youw

I am still in favour of merging this PR after your review. The reason is that High Speed USB HID devices are not that common. But you can decide.

@wulf7
Copy link
Copy Markdown

wulf7 commented Apr 25, 2026

It may not be an issue with this PR, but rather the hidraw driver issue under FreeBSD.

It is definitely FreeBSD usbhid issue or may be bad interaction between FreeBSD and VBox.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

It may not be an issue with this PR, but rather the hidraw driver issue under FreeBSD.

It is definitely FreeBSD usbhid issue or may be bad interaction between FreeBSD and VBox.

I will test with a physical machine tomorrow.

@aokblast
Copy link
Copy Markdown
Author

aokblast commented Apr 25, 2026

@aokblast @wulf7 and @cederom

So basically this PR works with Full Speed USB HID device, but somehow it does not work with High Speed USB HID device. It may not be an issue with this PR, but rather the hidraw driver issue under FreeBSD.

I will do a quick reviw from the AI comment again and do rebasing tomorrow.

@aokblast
Copy link
Copy Markdown
Author

Ouch. It seems that input is really 128 bytes no 129.

That should be the correct one.

The report ID 00 for the output report is not really on the wire. It is more needed because of Windows native HID API. The report ID 00 is also not on the wire.

Ah yes. Sorry for missing this.

FreeBSD support hidraw in Kernel from 13.0.
By using libusb only, we can only see the HID device from usb.
To address this, we implement hidraw backend for FreeBSD.

Just like Linux use libudev to handle usb specified HID stuff (like
Manufacture), we use libusb to handle it.

Sponsored-by: FreeBSD Foundation
Sponsored-by: Framework Laptop. Inc
@aokblast
Copy link
Copy Markdown
Author

I just rebase and clean up the commit. All AI's feedback is fixed.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 26, 2026

Preparing to test with a physical machine, an Chuwi mini PC with Intel J4125 CPU.

mcuee@freebsd14:~/build/hidapitester $ uname -a
FreeBSD freebsd14 15.0-RELEASE-p2 FreeBSD 15.0-RELEASE-p2 GENERIC amd64

mcuee@freebsd14:~/build/hidapitester $ fxload -v -D vid=0x04b4,pid=0x8613 -t fx2lp -I ../fx2hid/fx2hid/fx2hid.hex
microcontroller type: fx2lp
single stage:  load on-chip memory
open RAM hexfile image ../fx2hid/fx2hid/fx2hid.hex
stop CPU
write on-chip, addr 0x0600 len  234 (0x00ea)
write on-chip, addr 0x09d1 len   10 (0x000a)
write on-chip, addr 0x0380 len  428 (0x01ac)
write on-chip, addr 0x0080 len  768 (0x0300)
write on-chip, addr 0x0033 len    3 (0x0003)
write on-chip, addr 0x09eb len    4 (0x0004)
write on-chip, addr 0x08b6 len   44 (0x002c)
write on-chip, addr 0x0931 len   20 (0x0014)
write on-chip, addr 0x0887 len   47 (0x002f)
write on-chip, addr 0x05b8 len   70 (0x0046)
write on-chip, addr 0x0945 len   17 (0x0011)
write on-chip, addr 0x0043 len    3 (0x0003)
write on-chip, addr 0x0053 len    3 (0x0003)
write on-chip, addr 0x0700 len  184 (0x00b8)
write on-chip, addr 0x09ef len    3 (0x0003)
write on-chip, addr 0x07b8 len   92 (0x005c)
write on-chip, addr 0x090a len   39 (0x0027)
write on-chip, addr 0x05fe len    2 (0x0002)
write on-chip, addr 0x09f3 len    4 (0x0004)
write on-chip, addr 0x09db len    8 (0x0008)
write on-chip, addr 0x099c len   18 (0x0012)
write on-chip, addr 0x09e3 len    8 (0x0008)
write on-chip, addr 0x09ae len   18 (0x0012)
write on-chip, addr 0x09f7 len    6 (0x0006)
write on-chip, addr 0x08e2 len   40 (0x0028)
write on-chip, addr 0x0956 len   24 (0x0018)
write on-chip, addr 0x06ea len   22 (0x0016)
write on-chip, addr 0x0986 len   22 (0x0016)
write on-chip, addr 0x0851 len   54 (0x0036)
write on-chip, addr 0x096e len   24 (0x0018)
write on-chip, addr 0x0814 len   61 (0x003d)
write on-chip, addr 0x09fd len   36 (0x0024)
write on-chip, addr 0x0000 len    3 (0x0003)
write on-chip, addr 0x052c len   12 (0x000c)
write on-chip, addr 0x09c0 len   17 (0x0011)
write on-chip, addr 0x0538 len  128 (0x0080)
write on-chip, addr 0x09f2 len    1 (0x0001)
... WROTE: 2477 bytes, 37 segments, avg 66
reset CPU

mcuee@freebsd14:~/build/hidapitester $ sudo lsusb
Bus /dev/usb Device /dev/ugen0.6: ID 0925:1234 Lakeview Research 
Bus /dev/usb Device /dev/ugen0.10: ID 05e3:0747 Genesys Logic, Inc. 
Bus /dev/usb Device /dev/ugen0.9: ID 0bda:8156 Realtek Semiconductor Corp. 
Bus /dev/usb Device /dev/ugen0.8: ID 05e3:0625 Genesys Logic, Inc. 
Bus /dev/usb Device /dev/ugen0.7: ID 13d3:3503 IMC Networks 
Bus /dev/usb Device /dev/ugen0.5: ID 03eb:2106 Atmel Corp. STK600 development board
Bus /dev/usb Device /dev/ugen0.4: ID 05e3:0610 Genesys Logic, Inc. Hub
Bus /dev/usb Device /dev/ugen0.3: ID 25a7:fa61 Areson Technology Corp Elecom Co., Ltd MR-K013 Multicard Reader
Bus /dev/usb Device /dev/ugen0.2: ID 1ea7:0064 SHARKOON Technologies GmbH 2.4GHz Wireless rechargeable vertical mouse [More&Better]
Bus /dev/usb Device /dev/ugen0.1: ID 0000:0000  

mcuee@freebsd14:~/build/hidapitester $ sudo kldunload uhid
kldunload: can't find file uhid

mcuee@freebsd14:~/build/hidapitester $ ls -la /dev/hidraw*
crw-------  1 root operator  0x65 Apr 26 17:15 /dev/hidraw0
crw-------  1 root operator  0x6d Apr 26 17:15 /dev/hidraw1
crw-------  1 root operator  0x6e Apr 26 17:15 /dev/hidraw2
crw-------  1 root operator 0x1ba Apr 26 18:24 /dev/hidraw3

mcuee@freebsd14:~/build/hidapitester $ gmake
cc -I/usr/local/include -I ../hidapi/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c ../hidapi/libusb/hid.c -o ../hidapi/libusb/hid.o
cc -I/usr/local/include -I ../hidapi/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c hidapitester.c -o hidapitester.o
cc -I/usr/local/include -I ../hidapi/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" ../hidapi/libusb/hid.o hidapitester.o -o hidapitester -L/usr/local/lib -lusb -liconv -pthread

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester --list
1EA7/0064: (null) - 2.4G Mouse
25A7/FA61: Compx - 2.4G Receiver
25A7/FA61: Compx - 2.4G Receiver
0925/1234: CYPRESS - EZ-USB FX2 HID USBHIDIO

mcuee@freebsd14:~/build/hidapitester $ sudo chmod 666 /dev/hidraw3

mcuee@freebsd14:~/build/hidapitester $ ./hidapitester_freebsd_hidraw_pr730  --list
0925/1234: (null) - CYPRESS EZ-USB FX2 HID USBHIDIO

mcuee@freebsd14:~/build/hidapitester $ ./hidapitester_freebsd_hidraw_pr730 --vidpid 0925:1234 --list-detail
0925/1234: (null) - CYPRESS EZ-USB FX2 HID USBHIDIO
  vendorId:      0x0925
  productId:     0x1234
  usagePage:     0xFFA0
  usage:         0x0001
  serial_number: (null) 
  interface:     0 
  path: /dev/hidraw3

mcuee@freebsd14:~/build/hidapitester $ sudo usbconfig
ugen0.1: <XHCI root HUB Intel> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.2: <2.4GHz Wireless rechargeable vertical mouse [More&Better] SHARKOON Technologies GmbH> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.3: <Elecom Co., Ltd MR-K013 Multicard Reader Areson Technology Corp> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.4: <Hub Genesys Logic, Inc.> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen0.5: <STK600 development board Atmel Corp.> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (500mA)
ugen0.7: <product 0x3503 IMC Networks> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.8: <USB3.2 Hub Genesys Logic, Inc.> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.9: <USB 10/100/1G/2.5G LAN Realtek Semiconductor Corp.> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=ON (64mA)
ugen0.10: <USB Storage Genesys Logic, Inc.> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=ON (224mA)
ugen0.6: <EZ-USB FX2 HID USBHIDIO Lakeview Research> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (80mA)

mcuee@freebsd14:~/build/hidapitester $ sudo lsusb -vvv -d 0925:1234

Bus /dev/usb Device /dev/ugen0.6: ID 0925:1234 Lakeview Research 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0925 Lakeview Research
  idProduct          0x1234 
  bcdDevice            0.00
  iManufacturer           1 CYPRESS
  iProduct                2 EZ-USB FX2 HID USBHIDIO
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          3 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower               80mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      52
          Report Descriptor: (length is 52)
            Item(Global): Usage Page, data= [ 0xa0 0xff ] 65440
                            (null)
            Item(Local ): Usage, data= [ 0x01 ] 1
                            (null)
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Local ): Usage, data= [ 0x02 ] 2
                            (null)
            Item(Main  ): Collection, data= [ 0x00 ] 0
                            Physical
            Item(Global): Usage Page, data= [ 0xa1 0xff ] 65441
                            (null)
            Item(Local ): Usage, data= [ 0x03 ] 3
                            (null)
            Item(Local ): Usage, data= [ 0x04 ] 4
                            (null)
            Item(Global): Logical Minimum, data= [ 0x80 ] 128
            Item(Global): Logical Maximum, data= [ 0x7f ] 127
            Item(Global): Physical Minimum, data= [ 0x00 ] 0
            Item(Global): Physical Maximum, data= [ 0xff ] 255
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x05 ] 5
                            (null)
            Item(Local ): Usage, data= [ 0x06 ] 6
                            (null)
            Item(Global): Logical Minimum, data= [ 0x80 ] 128
            Item(Global): Logical Maximum, data= [ 0x7f ] 127
            Item(Global): Physical Minimum, data= [ 0x00 ] 0
            Item(Global): Physical Maximum, data= [ 0xff ] 255
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Main  ): Output, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
            Item(Main  ): End Collection, data=none
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         4
  bNumConfigurations      1
can't get debug descriptor: Input/output error
Device Status:     0x0002
  (Bus Powered)
  Remote Wakeup Enabled

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 26, 2026

Test log.

Edit: this test is not using the latest push today but previous version. I will test that later.

Interestingly it works every other time. Looks like there may be a data toggle related issues.

Supposedly EZ-USB FX2LP can handle data toggle bit automatically.

mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_hidraw_freebsd clean
rm -f ../hidapi_pr730/freebsd/hid.o hidapitester.o
rm -f hidapitester
mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_hidraw_freebsd 
cc -I/usr/local/include -I ../hidapi_pr730/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c ../hidapi_pr730/freebsd/hid.c -o ../hidapi_pr730/freebsd/hid.o
cc -I/usr/local/include -I ../hidapi_pr730/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c hidapitester.c -o hidapitester.o
cc -I/usr/local/include -I ../hidapi_pr730/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" ../hidapi_pr730/freebsd/hid.o hidapitester.o -o hidapitester -L/usr/local/lib -lusb -liconv -pthread
mcuee@freebsd14:~/build/hidapitester $ cp hidapitester hidapitester_hidraw_pr730 

mcuee@freebsd14:~/build/hidapitester $ ls -la
total 243
drwxr-xr-x   7 mcuee mcuee    21 Apr 26 18:50 .
drwxr-xr-x  24 mcuee mcuee    28 Sep 13  2025 ..
drwxr-xr-x   8 mcuee mcuee    15 Apr 26 17:18 .git
drwxr-xr-x   3 mcuee mcuee     3 Sep 29  2024 .github
-rw-r--r--   1 mcuee mcuee   577 Apr 26 17:18 .gitignore
drwxr-xr-x   2 mcuee mcuee     4 Apr 26 17:18 .vscode
-rw-r--r--   1 mcuee mcuee  1940 Apr 26 17:18 CMakeLists.txt
-rw-r--r--   1 mcuee mcuee 35149 Sep 29  2024 LICENSE
-rw-r--r--   1 mcuee mcuee  2323 Sep 29  2024 Makefile
-rw-r--r--   1 mcuee mcuee  2329 Mar 30  2025 Makefile_pr728
-rw-r--r--   1 mcuee mcuee  2329 Mar 30  2025 Makefile_pr730
-rw-r--r--   1 mcuee mcuee  2330 Mar 30  2025 Makefile_pr730_hidraw_freebsd
-rw-r--r--   1 mcuee mcuee  8328 Apr 26 17:18 README.md
drwxr-xr-x   2 mcuee mcuee     8 Sep 29  2024 docs
-rw-r--r--   1 mcuee mcuee 21029 Apr 26 17:18 hidapitester.c
-rwxr-xr-x   1 mcuee mcuee 43360 Apr 26 18:50 hidapitester_hidraw_pr730
-rwxr-xr-x   1 mcuee mcuee 55560 Apr 26 17:19 hidapitester_libusb_git
-rwxr-xr-x   1 mcuee mcuee 56256 Apr 26 18:42 hidapitester_libusb_pr728
-rwxr-xr-x   1 mcuee mcuee 55560 Apr 26 18:42 hidapitester_libusb_pr730
-rw-r--r--   1 mcuee mcuee  1525 Mar 31  2025 test.txt
drwxr-xr-x   6 mcuee mcuee     6 Sep 29  2024 test_hardware

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730  --vidpi
d 0925:1234 --o
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device
mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730  --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device
mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730  --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device
mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730  --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 26, 2026

The above is not the issue of this PR though. libusb backend has the same issue. So does PR #728.

Edit: this test is not using the latest push today but previous version. I will test that later.

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr728  --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr728  --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr728  --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr728  --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_git  --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_git  --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_git  --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_git  --vidpid
0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr730  --vidpi
d 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr730  --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr730  --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr730  --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 26, 2026

Using the latest git push of this PR #730.

mcuee@freebsd14:~/build $ git clone https://github.com/aokblast/hidapi.git -b use_hid_raw hidapi_pr730_new
Cloning into 'hidapi_pr730_new'...
remote: Enumerating objects: 3537, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 3537 (delta 0), reused 3 (delta 0), pack-reused 3533 (from 1)
Receiving objects: 100% (3537/3537), 3.30 MiB | 8.42 MiB/s, done.
Resolving deltas: 100% (2290/2290), done.

mcuee@freebsd14:~/build $ cd hidapitester/

mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_new clean
rm -f ../hidapi_pr730_new/libusb/hid.o hidapitester.o
rm -f hidapitester

mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_new 
cc -I/usr/local/include -I ../hidapi_pr730_new/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c ../hidapi_pr730_new/libusb/hid.c -o ../hidapi_pr730_new/libusb/hid.o
cc -I/usr/local/include -I ../hidapi_pr730_new/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c hidapitester.c -o hidapitester.o
cc -I/usr/local/include -I ../hidapi_pr730_new/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" ../hidapi_pr730_new/libusb/hid.o hidapitester.o -o hidapitester -L/usr/local/lib -lusb -liconv -pthread

mcuee@freebsd14:~/build/hidapitester $ cp ./hidapitester ./hidapitester_libusb_pr730_new

mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_new clean
rm -f ../hidapi_pr730_new/libusb/hid.o hidapitester.o
rm -f hidapitester

mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_hidraw_freebsd_new clean
rm -f ../hidapi_pr730_new/freebsd/hid.o hidapitester.o
rm -f hidapitester

mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_hidraw_freebsd_new 
cc -I/usr/local/include -I ../hidapi_pr730_new/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c ../hidapi_pr730_new/freebsd/hid.c -o ../hidapi_pr730_new/freebsd/hid.o
cc -I/usr/local/include -I ../hidapi_pr730_new/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c hidapitester.c -o hidapitester.o
cc -I/usr/local/include -I ../hidapi_pr730_new/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" ../hidapi_pr730_new/freebsd/hid.o hidapitester.o -o hidapitester -L/usr/local/lib -lusb -liconv -pthread

mcuee@freebsd14:~/build/hidapitester $ cp ./hidapitester ./hidapitester_hidraw_pr730_new

mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_hidraw_freebsd_new clean
rm -f ../hidapi_pr730_new/freebsd/hid.o hidapitester.o
rm -f hidapitester

mcuee@freebsd14:~/build/hidapitester $ ls
CMakeLists.txt				hidapitester.c
LICENSE					hidapitester_hidraw_pr730
Makefile				hidapitester_hidraw_pr730_new
Makefile_pr728				hidapitester_libusb_git
Makefile_pr730				hidapitester_libusb_pr728
Makefile_pr730_hidraw_freebsd		hidapitester_libusb_pr730
Makefile_pr730_hidraw_freebsd_new	hidapitester_libusb_pr730_new
Makefile_pr730_new			test.txt
README.md				test_hardware
docs

As expected, no changing of the test results.

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730_new  --vidpid 0925:1234
--open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730_new  --vidpid 0925:1234
--open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730_new  --vidpid 0925:1234
--open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730_new  --vidpid 0925:1234
--open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr730_new  --vidpid 0925:1234
--o
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr730_new  --vidpid 0925:1234
--open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr730_new  --vidpid 0925:1234
--open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr730_new  --vidpid 0925:1234
--open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 26, 2026

Now I will continue the 128bytes FX2HID mod firmware testing.

Unfortunately this PR does not work.

PR #728 also does not seems to work either. Strange.

mcuee@freebsd14:~/build/hidapitester $ sudo fxload -v -D vid=0x04b4,pid=0x8613 -t fx2lp -I ../fx2hid/fx2hid_128bytes_report/fx2hid_128bytes/fx2hid.hex
microcontroller type: fx2lp
single stage:  load on-chip memory
open RAM hexfile image ../fx2hid/fx2hid_128bytes_report/fx2hid_128bytes/fx2hid.hex
stop CPU
write on-chip, addr 0x0600 len  234 (0x00ea)
write on-chip, addr 0x09e5 len   10 (0x000a)
write on-chip, addr 0x0380 len  428 (0x01ac)
write on-chip, addr 0x0080 len  768 (0x0300)
write on-chip, addr 0x0033 len    3 (0x0003)
write on-chip, addr 0x09ff len    7 (0x0007)
write on-chip, addr 0x07b8 len   92 (0x005c)
write on-chip, addr 0x0851 len   59 (0x003b)
write on-chip, addr 0x05fe len    2 (0x0002)
write on-chip, addr 0x0a07 len    4 (0x0004)
write on-chip, addr 0x09ef len    8 (0x0008)
write on-chip, addr 0x09b0 len   18 (0x0012)
write on-chip, addr 0x09f7 len    8 (0x0008)
write on-chip, addr 0x09c2 len   18 (0x0012)
write on-chip, addr 0x0a0b len    6 (0x0006)
write on-chip, addr 0x091d len   40 (0x0028)
write on-chip, addr 0x096a len   24 (0x0018)
write on-chip, addr 0x06ea len   22 (0x0016)
write on-chip, addr 0x099a len   22 (0x0016)
write on-chip, addr 0x088c len   54 (0x0036)
write on-chip, addr 0x0982 len   24 (0x0018)
write on-chip, addr 0x0814 len   61 (0x003d)
write on-chip, addr 0x0a11 len   36 (0x0024)
write on-chip, addr 0x08f1 len   44 (0x002c)
write on-chip, addr 0x08c2 len   47 (0x002f)
write on-chip, addr 0x0945 len   20 (0x0014)
write on-chip, addr 0x05b8 len   70 (0x0046)
write on-chip, addr 0x0959 len   17 (0x0011)
write on-chip, addr 0x0043 len    3 (0x0003)
write on-chip, addr 0x0053 len    3 (0x0003)
write on-chip, addr 0x0700 len  184 (0x00b8)
write on-chip, addr 0x0000 len    3 (0x0003)
write on-chip, addr 0x052c len   12 (0x000c)
write on-chip, addr 0x09d4 len   17 (0x0011)
write on-chip, addr 0x0538 len  128 (0x0080)
write on-chip, addr 0x0a06 len    1 (0x0001)
... WROTE: 2497 bytes, 36 segments, avg 69
reset CPU

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730_new  --vidpid 0925:1234
--open --buflen 256 -l 129 --send-output 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 129-bytes...wrote 129 bytes:
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
 80
Reading up to 129-byte input report, 250 msec timeout...read 0 bytes:
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730_new  --vidpid 0925:1234
--open --buflen 256 -l 129 --send-output 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 129-bytes...wrote 129 bytes:
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
 80
Reading up to 129-byte input report, 250 msec timeout...read 0 bytes:
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr728  --vidpid 0925:1234 --open --buflen 256 -l 129 --send-output 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 129-bytes...wrote 129 bytes:
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
 80
Reading up to 129-byte input report, 250 msec timeout...read 0 bytes:
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr728  --vidpid 0925:1234 --open --buflen 256 -l 129 --send-output 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 129-bytes...wrote 129 bytes:
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
 80
Reading up to 129-byte input report, 250 msec timeout...read 0 bytes:
Closing device

Interestingly hidapi git libusb backend (same as PR#730 libusb backend works a bit better and returns 64 bytes of data. But there is an offset of 64 bytes.

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_git  --vidpid 0925:1234 --open --buflen 256 -l 129 --send-output 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 129-bytes...wrote 129 bytes:
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
 80
Reading up to 129-byte input report, 250 msec timeout...read 64 bytes:
 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60
 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr730_new  --vidpid 0925:1234
--open --buflen 256 -l 129 --send-output 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 129-bytes...wrote 129 bytes:
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
 80
Reading up to 129-byte input report, 250 msec timeout...read 64 bytes:
 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60
 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00
Closing device

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 26, 2026

Unfortunately I am not so sure how to force it to Full Speed mode using the physical machine.

mcuee@freebsd14:~/build/hidapitester $ sudo fxload -v -D vid=0x04b4,pid=0x8613 -t fx2lp -I ../fx2hid/fx2hid_128bytes_report/fx2hid_128bytes/fx2hid.hex
microcontroller type: fx2lpmicrocontroller type: fx2lp
single stage:  load on-chip memory
open RAM hexfile image ../fx2hid/fx2hid_128bytes_report/fx2hid_128bytes/fx2hid.hex
stop CPU
write on-chip, addr 0x0600 len  234 (0x00ea)
write on-chip, addr 0x09e5 len   10 (0x000a)
write on-chip, addr 0x0380 len  428 (0x01ac)
write on-chip, addr 0x0080 len  768 (0x0300)
write on-chip, addr 0x0033 len    3 (0x0003)
write on-chip, addr 0x09ff len    7 (0x0007)
write on-chip, addr 0x07b8 len   92 (0x005c)
write on-chip, addr 0x0851 len   59 (0x003b)
write on-chip, addr 0x05fe len    2 (0x0002)
write on-chip, addr 0x0a07 len    4 (0x0004)
write on-chip, addr 0x09ef len    8 (0x0008)
write on-chip, addr 0x09b0 len   18 (0x0012)
write on-chip, addr 0x09f7 len    8 (0x0008)
write on-chip, addr 0x09c2 len   18 (0x0012)
write on-chip, addr 0x0a0b len    6 (0x0006)
write on-chip, addr 0x091d len   40 (0x0028)
write on-chip, addr 0x096a len   24 (0x0018)
write on-chip, addr 0x06ea len   22 (0x0016)
write on-chip, addr 0x099a len   22 (0x0016)
write on-chip, addr 0x088c len   54 (0x0036)
write on-chip, addr 0x0982 len   24 (0x0018)
write on-chip, addr 0x0814 len   61 (0x003d)
write on-chip, addr 0x0a11 len   36 (0x0024)
write on-chip, addr 0x08f1 len   44 (0x002c)
write on-chip, addr 0x08c2 len   47 (0x002f)
write on-chip, addr 0x0945 len   20 (0x0014)
write on-chip, addr 0x05b8 len   70 (0x0046)
write on-chip, addr 0x0959 len   17 (0x0011)
write on-chip, addr 0x0043 len    3 (0x0003)
write on-chip, addr 0x0053 len    3 (0x0003)
write on-chip, addr 0x0700 len  184 (0x00b8)
write on-chip, addr 0x0000 len    3 (0x0003)
write on-chip, addr 0x052c len   12 (0x000c)
write on-chip, addr 0x09d4 len   17 (0x0011)
write on-chip, addr 0x0538 len  128 (0x0080)
write on-chip, addr 0x0a06 len    1 (0x0001)
... WROTE: 2497 bytes, 36 segments, avg 69
reset CPU
mcuee@freebsd14:~/build/hidapitester $ sudo usbconfig
ugen0.1: <XHCI root HUB Intel> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.2: <2.4GHz Wireless rechargeable vertical mouse [More&Better] SHARKOON Technologies GmbH> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.3: <Elecom Co., Ltd MR-K013 Multicard Reader Areson Technology Corp> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.4: <Hub Genesys Logic, Inc.> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen0.5: <STK600 development board Atmel Corp.> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (500mA)
ugen0.7: <product 0x3503 IMC Networks> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.8: <USB3.2 Hub Genesys Logic, Inc.> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.9: <USB 10/100/1G/2.5G LAN Realtek Semiconductor Corp.> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=ON (64mA)
ugen0.10: <USB Storage Genesys Logic, Inc.> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=ON (224mA)
ugen0.6: <EZ-USB FX2 HID USBHIDIO Lakeview Research> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (80mA)

I already applied the changes to /boot/loader.conf and reboot the machine.

mcuee@freebsd14:~/build/hidapitester $ sudo cat /boot/loader.conf
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gptid.enable="0"
cryptodev_load="YES"
zfs_load="YES"
hidraw_load="YES"
hw.usb.ehci.no_hs="1"

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 26, 2026

The following bootloader.conf does not work either even after the reboot.

mcuee@freebsd14:~/build/hidapitester $ uname -a
FreeBSD freebsd14 15.0-RELEASE-p6 FreeBSD 15.0-RELEASE-p6 GENERIC amd64

mcuee@freebsd14:~/build/hidapitester $ sudo cat /boot/loader.conf
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gptid.enable="0"
cryptodev_load="YES"
zfs_load="YES"
hidraw_load="YES"
#hw.usb.ehci.no_hs="1"
hint.ehci.0.disabled="1"
hint.ehci.1.disabled="1"

mcuee@freebsd14:~/build/hidapitester $ sudo kldstat
Id Refs Address                Size Name
 1  140 0xffffffff80200000  1f4dad0 kernel
 2    1 0xffffffff8214f000     79b0 hidraw.ko
 3    1 0xffffffff82157000   620c10 zfs.ko
 4    1 0xffffffff82778000     8808 cryptodev.ko
 5    1 0xffffffff831e5000     3570 fdescfs.ko
 6    1 0xffffffff83200000   210318 i915kms.ko
 7    2 0xffffffff83411000    8a190 drm.ko
 8    1 0xffffffff831e9000     22b8 iic.ko
 9    2 0xffffffff831ec000     4120 linuxkpi_video.ko
10    3 0xffffffff831f1000     7358 dmabuf.ko
11    3 0xffffffff831f9000     3378 lindebugfs.ko
12    1 0xffffffff8349c000     b480 ttm.ko
13    1 0xffffffff831fd000     21e8 hcons.ko
14    3 0xffffffff834a8000     30a8 hidmap.ko
15    1 0xffffffff834ac000     21e8 hms.ko
16    1 0xffffffff834af000     21e8 hsctrl.ko
17    1 0xffffffff834b2000     4250 ichsmb.ko
18    1 0xffffffff834b7000     2178 smbus.ko
19    1 0xffffffff834ba000     6210 ig4.ko
20    1 0xffffffff834c1000    32320 linux.ko
21    2 0xffffffff834f4000     6d98 mqueuefs.ko
22    4 0xffffffff834fb000     ce68 linux_common.ko
23    1 0xffffffff83508000    2e3f0 linux64.ko
24    1 0xffffffff83537000     2278 pty.ko
25    1 0xffffffff8353a000     73c0 linprocfs.ko
26    1 0xffffffff83542000     440c linsysfs.ko
27    1 0xffffffff83547000     58c0 ng_ubt.ko
28    7 0xffffffff8354d000     abb8 netgraph.ko
29    3 0xffffffff83558000     a330 ng_hci.ko
30    4 0xffffffff83563000     2670 ng_bluetooth.ko
31    1 0xffffffff83566000     8580 if_ure.ko
32    1 0xffffffff8356f000     31d0 uether.ko
33    1 0xffffffff83573000     e4a8 ng_l2cap.ko
34    1 0xffffffff83582000    1c0c8 ng_btsocket.ko
35    1 0xffffffff8359f000     3908 ng_socket.ko
36    1 0xffffffff835a3000     4860 nullfs.ko
37    1 0xffffffff835a8000     2a80 mac_ntpd.ko

mcuee@freebsd14:~/build/hidapitester $ sudo usbconfig
ugen0.1: <XHCI root HUB Intel> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.2: <2.4GHz Wireless rechargeable vertical mouse [More&Better] SHARKOON Technologies GmbH> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.3: <Elecom Co., Ltd MR-K013 Multicard Reader Areson Technology Corp> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.4: <Hub Genesys Logic, Inc.> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen0.5: <STK600 development board Atmel Corp.> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (500mA)
ugen0.6: <EZ-USB FX2 HID USBHIDIO Lakeview Research> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (80mA)
ugen0.7: <product 0x3503 IMC Networks> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.8: <USB3.2 Hub Genesys Logic, Inc.> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.9: <USB 10/100/1G/2.5G LAN Realtek Semiconductor Corp.> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=ON (64mA)
ugen0.10: <USB Storage Genesys Logic, Inc.> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=ON (224mA)

@aokblast
Copy link
Copy Markdown
Author

Using the latest git push of this PR #730.

mcuee@freebsd14:~/build $ git clone https://github.com/aokblast/hidapi.git -b use_hid_raw hidapi_pr730_new
Cloning into 'hidapi_pr730_new'...
remote: Enumerating objects: 3537, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 3537 (delta 0), reused 3 (delta 0), pack-reused 3533 (from 1)
Receiving objects: 100% (3537/3537), 3.30 MiB | 8.42 MiB/s, done.
Resolving deltas: 100% (2290/2290), done.

mcuee@freebsd14:~/build $ cd hidapitester/

mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_new clean
rm -f ../hidapi_pr730_new/libusb/hid.o hidapitester.o
rm -f hidapitester

mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_new 
cc -I/usr/local/include -I ../hidapi_pr730_new/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c ../hidapi_pr730_new/libusb/hid.c -o ../hidapi_pr730_new/libusb/hid.o
cc -I/usr/local/include -I ../hidapi_pr730_new/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c hidapitester.c -o hidapitester.o
cc -I/usr/local/include -I ../hidapi_pr730_new/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" ../hidapi_pr730_new/libusb/hid.o hidapitester.o -o hidapitester -L/usr/local/lib -lusb -liconv -pthread

mcuee@freebsd14:~/build/hidapitester $ cp ./hidapitester ./hidapitester_libusb_pr730_new

mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_new clean
rm -f ../hidapi_pr730_new/libusb/hid.o hidapitester.o
rm -f hidapitester

mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_hidraw_freebsd_new clean
rm -f ../hidapi_pr730_new/freebsd/hid.o hidapitester.o
rm -f hidapitester

mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_hidraw_freebsd_new 
cc -I/usr/local/include -I ../hidapi_pr730_new/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c ../hidapi_pr730_new/freebsd/hid.c -o ../hidapi_pr730_new/freebsd/hid.o
cc -I/usr/local/include -I ../hidapi_pr730_new/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c hidapitester.c -o hidapitester.o
cc -I/usr/local/include -I ../hidapi_pr730_new/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" ../hidapi_pr730_new/freebsd/hid.o hidapitester.o -o hidapitester -L/usr/local/lib -lusb -liconv -pthread

mcuee@freebsd14:~/build/hidapitester $ cp ./hidapitester ./hidapitester_hidraw_pr730_new

mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_hidraw_freebsd_new clean
rm -f ../hidapi_pr730_new/freebsd/hid.o hidapitester.o
rm -f hidapitester

mcuee@freebsd14:~/build/hidapitester $ ls
CMakeLists.txt				hidapitester.c
LICENSE					hidapitester_hidraw_pr730
Makefile				hidapitester_hidraw_pr730_new
Makefile_pr728				hidapitester_libusb_git
Makefile_pr730				hidapitester_libusb_pr728
Makefile_pr730_hidraw_freebsd		hidapitester_libusb_pr730
Makefile_pr730_hidraw_freebsd_new	hidapitester_libusb_pr730_new
Makefile_pr730_new			test.txt
README.md				test_hardware
docs

As expected, no changing of the test results.

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730_new  --vidpid 0925:1234
--o
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730_new  --vidpid 0925:1234
--open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730_new  --vidpid 0925:1234
--open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730_new  --vidpid 0925:1234
--open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr730_new  --vidpid 0925:1234
--o
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr730_new  --vidpid 0925:1234
--open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr730_new  --vidpid 0925:1234
--open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device

mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_libusb_pr730_new  --vidpid 0925:1234
--open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

This looks like a firmware bug, right?

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 27, 2026

This looks like a firmware bug, right?

Not really in this particular case.

More like a FreeBSD USB bug to me since other Operating Systems have no issues.

Also EZ-USB FX2LP is supposed to handle data toggle correctly from HW side.

BTW, this original FW comes from Jan Axelson, no modification from my side.

If possible, please get the cheap EZ-FX2LP board from online store and try yourself.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 27, 2026

For anyone interested in High Speed USB development and testing, EZ-USB FX2LP is highly recommended. The board is pretty cheap to get from 3rd party vendors (cheap clone of CY3689 EZ-USB FX2LP Discovery Kit)
https://www.infineon.com/assets/row/public/documents/24/44/infineon-cy3689-ez-usb-fx2lp-discovery-kit-quick-start-guide-usermanual-en.pdf

For anyone interested in Super Speed USB development and testing, EZ-USB FX3 is highly recommended. The board is not that cheap but still manageable. It used to be at around US$50 but now it is at US$90.15.
https://www.infineon.com/evaluation-board/cyusb3kit-003

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 27, 2026

I am stilll using VirtualBox VM under Windows 11 for this test, but I have switched the VM back to the default USB configuration (OHCI + EHCI).

PS C:\Program Files\Oracle\VirtualBox> .\VBoxManage modifyvm "freebsd" --usb-ohci on --usb-ehci on --usb-xhci off

Then I use my trusted modified Generic PIC USB HID example (modified from the Lakeview Research Generic HID example to add Input/Output/Feature report IDs). It is a Full Speed USB device.

It was mentioned in the following discussion.
#590

FW source code and old libusb test codes are here.
https://github.com/mcuee/picusb/tree/master/lvr_genhid_mod

The device works well under Windows.

PS C:\work\libusb\hidapitester> .\hidapitester_git_winapi.exe --vidpid 0925:7001 --open --buflen 64 -l 3 --send-output 2,1,2  --read-input
Opening device, vid/pid: 0x0925/0x7001
Writing output report of 3-bytes...wrote 3 bytes:
 02 01 02
Reading up to 3-byte input report, 250 msec timeout...read 3 bytes:
 01 01 02
Closing device

PS C:\work\libusb\hidapitester> .\hidapitester_git_winapi.exe --vidpid 0925:7001 --open --buflen 64 -l 3 --send-feature 3,7,8  --read-feature 4
Opening device, vid/pid: 0x0925/0x7001
Writing 3-byte feature report...wrote 3 bytes:
 03 07 08
Reading 3-byte feature report, report_id 4...read 3 bytes:
 04 07 08
Closing device

It also works fine with this PR under FreeBSD VM.

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw_new  --vidpid 0925:7001 --open --buflen 64 -l 3 --send-output 2,5,6  --read-input
Opening device, vid/pid: 0x0925/0x7001
Writing output report of 3-bytes...wrote 3 bytes:
 02 05 06
Reading up to 3-byte input report, 250 msec timeout...read 3 bytes:
 01 05 06
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw_new  --vidpid 0925:7001 --open --buflen 64 -l 3 --send-output 2,5,6  --read-input
Opening device, vid/pid: 0x0925/0x7001
Writing output report of 3-bytes...wrote 3 bytes:
 02 05 06
Reading up to 3-byte input report, 250 msec timeout...read 3 bytes:
 01 05 06
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw_new  --open --buflen 64 -l 3 --send-feature 3,5,6  --read-feature 4
Opening device, vid/pid:0x0000/0x0000, usagePage/usage: 0/0
Device opened
Writing 3-byte feature report...wrote 3 bytes:
 03 05 06
Reading 3-byte feature report, report_id 4...read 3 bytes:
 04 05 06
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw_new  --open --buflen 64 -l 3 --send-feature 3,5,6  --read-feature 4
Opening device, vid/pid:0x0000/0x0000, usagePage/usage: 0/0
Device opened
Writing 3-byte feature report...wrote 3 bytes:
 03 05 06
Reading 3-byte feature report, report_id 4...read 3 bytes:
 04 05 06
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo lsusb -d 0925:7001 -vvv

Bus /dev/usb Device /dev/ugen0.2: ID 0925:7001 Lakeview Research
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x0925 Lakeview Research
  idProduct          0x7001
  bcdDevice            0.01
  iManufacturer           1 Lakeview Research
  iProduct                2 Generic HID
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      45
          Report Descriptor: (length is 45)
            Item(Global): Usage Page, data= [ 0x00 0xff ] 65280
                            (null)
            Item(Local ): Usage, data= [ 0x01 ] 1
                            (null)
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Global): Report ID, data= [ 0x01 ] 1
            Item(Local ): Usage, data= [ 0x00 ] 0
                            (null)
            Item(Main  ): Input, data= [ 0x02 0x01 ] 258
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Buffered Bytes
            Item(Global): Report ID, data= [ 0x02 ] 2
            Item(Local ): Usage, data= [ 0x00 ] 0
                            (null)
            Item(Main  ): Output, data= [ 0x02 0x01 ] 258
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Buffered Bytes
            Item(Global): Report ID, data= [ 0x03 ] 3
            Item(Local ): Usage, data= [ 0x00 ] 0
                            (null)
            Item(Main  ): Feature, data= [ 0x02 0x01 ] 258
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Buffered Bytes
            Item(Global): Report ID, data= [ 0x04 ] 4
            Item(Local ): Usage, data= [ 0x00 ] 0
                            (null)
            Item(Main  ): Feature, data= [ 0x02 0x01 ] 258
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Buffered Bytes
            Item(Main  ): End Collection, data=none
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
can't get device qualifier: Input/output error
can't get debug descriptor: Input/output error
Device Status:     0x0001
  Self Powered

@aokblast
Copy link
Copy Markdown
Author

EZ-USB FX2LP

Just buy a EZ-USB FX2LP. I spend two days on configuring stm32h750 + usb3320 and it fails. I think there are some design flaws on stm32h750 as some pin output doesn't follow the ulpi standard.

See: https://community.st.com/t5/stm32-mcus-embedded-software/stm32h750-usb3300-no-signals-on-ulpi/td-p/225293?fbclid=IwY2xjawRdSk5leHRuA2FlbQIxMABicmlkETF1eVg0M2d2OENpV1lWdnpjc3J0YwZhcHBfaWQQMjIyMDM5MTc4ODIwMDg5MgABHr4fjotlcri4aRfLeR3qxxa3_rOWLG8XdiaZHQXLlSejiReV3U-u7F052oj-_aem_DLqIO7VIk_LDjl6YhWkqEw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bsd FreeBSD, NetBSD, OpenBSD, etc enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants